<template>
  <div>
    <el-form :model="queryParam" :inline=true style="display: flex">
      <el-form-item label="fieldId">
        <el-input v-model="queryParam.fieldId" style="width:160px"/>
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="queryParam.fieldCn" style="width:160px"/>
      </el-form-item>
      <el-form-item label="取值">
        <el-input v-model="queryParam.selectParamDirect" style="width:160px"/>
      </el-form-item>
      <el-form-item label="intId">
        <el-input v-model="queryParam.intId" style="width:160px"/>
      </el-form-item>
      <el-form-item label="脚本">
        <el-input v-model="queryParam.selectParamScript" style="width:160px"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="queryPage">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="intId" label="intId" width="60"></el-table-column>
      <el-table-column label="参数">
        <template slot-scope="scope">
          <div class="typeEnter">fieldId：{{ scope.row.fieldId }}</div>
          <div class="typeEnter">名称：{{ scope.row.fieldCn }}</div>
          <div class="typeEnter">取值：{{ scope.row.selectParamDirect }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="selectParamScript" label="groovy脚本" width="280"></el-table-column>
      <el-table-column prop="products" label="关联项目" width="300">
        <template slot-scope="scope">
          <span v-for="(item,index) in scope.row.products">{{ item.productCode + ':' + item.riskType + ',' }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="locals" label="本地变量" width="220">
        <template slot-scope="scope">
          <span v-for="(item,index) in scope.row.locals">{{ item.intClass + '.' + item.intMethod }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="pageTotal>0"
      :total="pageTotal"
      :page.sync="queryParam.pageNum"
      :limit.sync="queryParam.pageSize"
      @pagination="queryPage"
    />
  </div>
</template>
<script>

export default {
  data() {
    return {
      // 查询参数
      pageTotal: 0,
      queryParam: {
        fieldId: '',
        fieldCn: '',
        intId: '',
        selectParamDirect: '',
        selectParamScript: '',
        pageNum: 1,
        pageSize: 10
      },
      tableData: []
    }
  },
  mounted() {
    this.pageList()
  },
  methods: {
    queryPage() {
      var _this = this
      _this.pageList()
    },
    pageList() {
      var _this = this
      this.$api.risk1datafieldconfPageList(_this.queryParam).then(res => {
        if (res.code === '00000') {
          _this.tableData = res.data.pageList
          _this.pageTotal = res.data.pageTotal
        } else {
          _this.$message(res.msg)
        }
      }).catch(e => {
        console.log('接口访问异常!')
      })
    }
  }
}
</script>
